home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / sys / amiga / programmer / 7153 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  2.0 KB

  1. Path: comma.rhein.de!serpens!not-for-mail
  2. From: mlelstv@serpens.rhein.de (Michael van Elst)
  3. Newsgroups: comp.sys.amiga.programmer
  4. Subject: Re: Messages vs. Semaphores for external clocking
  5. Date: 10 Apr 1996 16:46:42 +0200
  6. Organization: dis-
  7. Message-ID: <4kghki$bog@serpens.rhein.de>
  8. References: <4ju349$r1e@sparky.navsea.navy.mil> <4jvrqs$hk0@btmpjg.god.bel.alcatel.be> <heinz.17rm@hwg.muc.de> <4kfmes$lle@btmpjg.god.bel.alcatel.be> <4kfuhb$ahh@serpens.rhein.de> <4kg2qq$58l@btmpjg.god.bel.alcatel.be>
  9. NNTP-Posting-Host: serpens.rhein.de
  10.  
  11. barnhoorn@nlev00 () writes:
  12.  
  13. >>No. You stop all other tasks (and with Disable() you even stop
  14. >>interrupts which is nonsense). 
  15.  
  16. >Agree (I meant Forbid()/Permit()). But 'you stop all other tasks'
  17. >is wrong. In my Amiga only ONE task is running at the same time.
  18.  
  19. You stop all other tasks because you prevent that _any_ task preempts
  20. you instead of just the task that wants to access the shared data.
  21.  
  22. >When task 1 wants the data, the only thing it has to do is disable
  23. >multitasking, (which does NOT stop all other tasks because they are
  24. >already stopped),
  25.  
  26. It does stop all other tasks because other tasks cannot be scheduled.
  27.  
  28. >        Forbid();
  29. >        local_data=global_data;
  30. >        Permit();
  31.  
  32. And now make the data some kilobytes in size and watch multitasking
  33. degrade by several magnitudes.
  34.  
  35. Using semaphores ensures that you disable multitasking only for a
  36. minimal period.
  37.  
  38. >I really only wanted to state that in my opinion, forbid() and permit()
  39. >is the most easiest, shortest and probably also fastest way to transfer
  40. >the data from task2 to task1.
  41.  
  42. ObtainSemaphore()/ReleaseSemaphore() is as easy. It is minimally slower
  43. (because it calls Forbid() internally) but it doesn't degrade performance
  44. if the protected operation takes more than coyping a single word.
  45.  
  46. BTW, using semaphores is also a good way to ensure efficient operation
  47. if AmigaOS ever supports multiple processors.
  48.  
  49. Regards,
  50. -- 
  51.                                 Michael van Elst
  52.  
  53. Internet: mlelstv@serpens.rhein.de
  54.                                 "A potential Snark may lurk in every tree."
  55.